package com.dian.diabetes.db.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;

import com.dian.diabetes.db.dao.UserDao;
import com.dian.diabetes.db.dao.DiabetesDao;
import com.dian.diabetes.db.dao.DiabetesCacheDao;
import com.dian.diabetes.db.dao.SportDao;
import com.dian.diabetes.db.dao.DefSetDao;
import com.dian.diabetes.db.dao.EatDao;
import com.dian.diabetes.db.dao.ReportDao;
import com.dian.diabetes.db.dao.AlarmDao;
import com.dian.diabetes.db.dao.UserSetDao;
import com.dian.diabetes.db.dao.CommonDao;
import com.dian.diabetes.db.dao.UserInfoDao;
import com.dian.diabetes.db.dao.PlanDao;
import com.dian.diabetes.db.dao.MedicineDao;
import com.dian.diabetes.db.dao.NewsDao;
import com.dian.diabetes.db.dao.FavorateDao;
import com.dian.diabetes.db.dao.NormalDao;
import com.dian.diabetes.db.dao.IndicateDao;
import com.dian.diabetes.db.dao.IndicateValueDao;
import com.dian.diabetes.db.dao.AlarmHistoryDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * Master of DAO (schema version 1): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 1;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
        UserDao.createTable(db, ifNotExists);
        DiabetesDao.createTable(db, ifNotExists);
        DiabetesCacheDao.createTable(db, ifNotExists);
        SportDao.createTable(db, ifNotExists);
        DefSetDao.createTable(db, ifNotExists);
        EatDao.createTable(db, ifNotExists);
        ReportDao.createTable(db, ifNotExists);
        AlarmDao.createTable(db, ifNotExists);
        UserSetDao.createTable(db, ifNotExists);
        CommonDao.createTable(db, ifNotExists);
        UserInfoDao.createTable(db, ifNotExists);
        PlanDao.createTable(db, ifNotExists);
        MedicineDao.createTable(db, ifNotExists);
        NewsDao.createTable(db, ifNotExists);
        FavorateDao.createTable(db, ifNotExists);
        NormalDao.createTable(db, ifNotExists);
        IndicateDao.createTable(db, ifNotExists);
        IndicateValueDao.createTable(db, ifNotExists);
        AlarmHistoryDao.createTable(db, ifNotExists);
    }
    
    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
        UserDao.dropTable(db, ifExists);
        DiabetesDao.dropTable(db, ifExists);
        DiabetesCacheDao.dropTable(db, ifExists);
        SportDao.dropTable(db, ifExists);
        DefSetDao.dropTable(db, ifExists);
        EatDao.dropTable(db, ifExists);
        ReportDao.dropTable(db, ifExists);
        AlarmDao.dropTable(db, ifExists);
        UserSetDao.dropTable(db, ifExists);
        CommonDao.dropTable(db, ifExists);
        UserInfoDao.dropTable(db, ifExists);
        PlanDao.dropTable(db, ifExists);
        MedicineDao.dropTable(db, ifExists);
        NewsDao.dropTable(db, ifExists);
        FavorateDao.dropTable(db, ifExists);
        NormalDao.dropTable(db, ifExists);
        IndicateDao.dropTable(db, ifExists);
        IndicateValueDao.dropTable(db, ifExists);
        AlarmHistoryDao.dropTable(db, ifExists);
    }
    
    public static abstract class OpenHelper extends SQLiteOpenHelper {

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }
    
    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

    public DaoMaster(SQLiteDatabase db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(UserDao.class);
        registerDaoClass(DiabetesDao.class);
        registerDaoClass(DiabetesCacheDao.class);
        registerDaoClass(SportDao.class);
        registerDaoClass(DefSetDao.class);
        registerDaoClass(EatDao.class);
        registerDaoClass(ReportDao.class);
        registerDaoClass(AlarmDao.class);
        registerDaoClass(UserSetDao.class);
        registerDaoClass(CommonDao.class);
        registerDaoClass(UserInfoDao.class);
        registerDaoClass(PlanDao.class);
        registerDaoClass(MedicineDao.class);
        registerDaoClass(NewsDao.class);
        registerDaoClass(FavorateDao.class);
        registerDaoClass(NormalDao.class);
        registerDaoClass(IndicateDao.class);
        registerDaoClass(IndicateValueDao.class);
        registerDaoClass(AlarmHistoryDao.class);
    }
    
    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }
    
    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }
    
}
